<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Account extends MY_Controller {
	
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		$user = $this->session->userdata('zjy_user');
		if(!isset($user['user_id']) || !$user['user_id']){
			$str = $_SERVER['REQUEST_URI'];
			header('Location: /login.html');
			exit;
		}
		
		$this->tab = 'user';
		$this->sub = 'account';
	}
	
	
	public function recharge(){
		$act = $this->input->post('act');
		$user = $this->session->userdata('zjy_user');
		$this->load->helper('captcha');
		
		$data = $this->get_user_info('account_recharge','account_info');
		$this->load->model('User_model', 'user');
		$this->load->model('Payment_model', 'payment');
		$data['payment_list']=$this->payment->get_list();
		$data['var_payment_bank'] 		= $this->payment->arrays('var_payment_bank');
		
		
		if($act == 'submit'){
			$msg = '';
			$time = time();
			$type  = 1;
			$money = $this->input->post('money');
			$captcha = $this->input->post('captcha');
			if($captcha == ''){
				$msg = '验证码不能为空';
			}elseif ($captcha!=$_SESSION['captcha']){
				$msg = '验证码不正确';
			}elseif(!is_numeric($money)){
				$msg = '无效的金额';
			}else{
				$money = round($money,2);	
				if($money < 0){
					$msg = '无效的金额';
				}else{
//					if($msg==''){
//						$recharge = array(
//							'user_id' => $user['user_id'],
//							'trade_no' => $time.$user['user_id'].rand(1,9),
//							'fstatus' => 0,
//							'money' => $money,
//							'payment' => 1,
//							'freturn' => '',
//							'ftype' => $type,
//							'remark' => "在线充值",
//							'fee' => 0,
//							'verify_userid' => 0,
//							'verify_time' => $time,
//							'verify_ip' => '',
//							'verify_remark' => '',
//							'add_time' => $time,
//							'addip' => $this->input->ip_address()
//						);
//						$this->load->model('Accountrecharge_model', 'recharge');
//						$res = $this->recharge->add($recharge);
//
//						if($res > 0){
//							header("Location:/moneymoremore/toloanrecharge/".$res);
//							exit;
//						}else{
//							$msg = '提交失败';
//						}
//					}
                    if ($type == '1') {//网上充值
                        $bank_fun = '';
                        $bank_code = '';
                        $bank_str = $this->input->post('bankRadio');
                        $payment1 = $this->input->post('payment1');
                        if ((isset($bank_str) && $bank_str != '') && (isset($payment1) && $payment1 != '')) {
                            $msg = '只能选择一种支付方式';
                        }

                        if (isset($bank_str) && $bank_str != '') {
                            $bank = explode("|", $bank_str);
                            $payment = $bank[1];
                            $bank_code = $bank[0];
                            $bank_fun = $bank[2];
                        } elseif (isset($payment1) && $payment1 != '') {
                            $payment = $payment1;
                        } else {
                            $msg = '请选择银行卡或者第三方支付平台';
                        }


                        $remark = $this->input->post('payname' . $payment) . '在线充值';
                        $timetmp = strtotime('2013-10-01 00:00:00');
                        if ($payment == 11 && time() < $timetmp) {//宝付
                            $fee = $money * 0.001; //收取千分之一
                            $fee = ceil($fee * 100) * 0.01; //保留2位小数  0舍1入
                        } else {
                            $fee = 0;
                        }
                    }

                    if ($msg == '') {
                        $recharge = array(
                            'user_id' => $user['user_id'],
                            'trade_no' => $time . $user['user_id'] . rand(1, 9),
                            'fstatus' => 0,
                            'money' => $money,
                            'payment' => $payment,
                            'freturn' => '',
                            'ftype' => $type,
                            'remark' => $remark,
                            'fee' => $fee,
                            'verify_userid' => 0,
                            'verify_time' => $time,
                            'verify_ip' => '',
                            'verify_remark' => '',
                            'add_time' => $time,
                            'addip' => $this->input->ip_address()
                        );

                        $this->load->model('Accountrecharge_model', 'recharge');
                        $res = $this->recharge->add($recharge);

                        if ($res > 0) {
                            if ($type == 1) {//网上充值
                                $this->load->model('Payment_model', 'payment');

                                $recharge['bank'] = $bank_fun;
                                $recharge['bankAbbr'] = $bank_code;

                                $this->payment->submit($recharge);
                            } elseif ($type == 2) {//用户线下充值
                                $msg = '充值已提交，请等待审核';
                            }
                        } else {
                            $msg = '提交失败';
                        }
                    }
				}
			}
			$data['msg'] = $msg;
		}else{
			$data['msg'] = '';			
		}
		$data['title'] = "账户充值".' - '.CON_KEYWORDS;
        $data['tab_first'] = 'fund';
        $data['tab_second'] = 'fund_recharge';
		$this->load->view('account/account_recharge',$data);
			
		
	}
	
	
	function recharge_log(){
		$user = $this->session->userdata('zjy_user');
		$data = array();
		$parms['page_start'] = intval($this->input->get('per_page'));
		$parms['page_size'] = 20;
		$parms['where']['user_id'] = $user['user_id'];
		$this->load->model('Accountrecharge_model', 'recharge');
		$this->load->model('Payment_model', 'payment');
		//充值统计
		
		$data = $this->get_user_info('account_recharge_log','account_info');
		
		
		$resData = $this->recharge->get_accountrecharge_list($parms);
		$data['list'] = $resData['accountrecharge_list'];
		$data['recharge_status'] 	= $this->recharge->arrays("account_recharge_status");
		$data['recharge_type'] 	= $this->recharge->arrays("account_recharge_type");
		$data['payment_list'] = $this->payment->get_list();
		$data['group_total'] = $this->recharge->get_recharge_group_sum($user['user_id']);
		$this->load->library('pagination');
		$config['base_url'] = '/account/recharge_log/index.html?';
		$config['total_rows'] = $resData['accountrecharge_count'];
		$config['per_page'] = 20;
		$config['first_link'] = '首页';
		$config['next_link'] = '下一页';
		$config['prev_link'] = '上一页';
		$config['last_link'] = '尾页';
		$this->pagination->initialize($config);
		
		
		$data['title'] = "充值记录".' - '.CON_KEYWORDS;
        $data['tab_first'] = 'fund';
        $data['tab_second'] = 'fund_recharge';
		$this->load->view('/account/account_recharge_log', $data);
	}
	
	
	function bank(){
		$user = $this->session->userdata('zjy_user');
		$act = $this->input->post('act');
		$this->load->model('Account_bank_model', 'bank');
		$msg = '';
		$this->load->helper('captcha');
		
		if($act == 'submit'){
			$bank = $this->bank->get_by_uid($user['user_id']);
			if($bank){
				//$this->js->alert('银行账户一经填写不能修改');
				//$this->js->go('');
				echo '银行账户一经填写不能修改';
				exit;
			}else{
				$captcha = $this->input->post('captcha');
				if($captcha == ''){
					//$this->js->alert('验证码不能为空');
					//$this->js->go('');
					echo '验证码不能为空';
					exit;
				}
				if ($captcha!=$_SESSION['captcha']){
					//$this->js->alert('验证码不正确');
					//$this->js->go('');
					echo '验证码不正确';
					exit;
				}
				$setArr = array(
					'user_id' => $user['user_id'],
					'account' => $this->input->post('account'),
					'bank' => $this->input->post('bank'),
					'province' => $this->input->post('province'),
					'city' => $this->input->post('city'),
					'area' => 1,
					'branch' => $this->input->post('branch'),
					'add_time' => time(),
					'addip' => $this->input->ip_address(),
				); 
				foreach ($setArr as $v){
					if(!$v){
						echo '银行账户一经填写不得随意更改，请仔细填写完整';
						exit; 
					}
				}
				
				
				$id = $this->bank->add($setArr);
				if($id>0){
					echo '';
					exit;
				}else{
					echo '保存失败';
					exit;
				}
				
			}
		}else{
			$this->load->model('User_model', 'user');
			$this->load->model('Area_model', 'area');
			$data = $this->get_user_info('account_bank','bank');
			
			$data['area'] = $this->area->get_list1();
			$data['bank_list'] = $this->bank->arrays('var_account_bank');
			$data['bank'] = $this->bank->get_by_uid($user['user_id']);
			
			$data['title'] = "银行账户".' - '.CON_KEYWORDS;
            $data['tab_first'] = 'fund';
            $data['tab_second'] = 'fund_bank';
			$this->load->view('account/account_bank', $data);
		}
	}
	
	function cash(){
		$act = $this->input->post('act');
		$user = $this->session->userdata('zjy_user');
		$this->load->helper('captcha');
		
		$this->load->model('User_model', 'user');
		$this->load->model('Account_bank_model', 'bank');
		$this->load->model('Account_model', 'account');
		$this->load->model('Accountlog_model', 'accountlog');
		$this->load->model('Area_model', 'area');
        $this->load->model('Message_model');
		
		$data = $this->get_user_info('account_cash','account_info');
		
		
		$data['area'] = $this->area->get_list1();
		$data['bank_list'] = $this->bank->arrays('var_account_bank');
		$data['user'] = $this->user->get_by_uid($user['user_id']);
		$data['account'] = $this->account->get_account($user['user_id']);
		$data['bank'] = $this->bank->get_by_uid($user['user_id']);
		$data['cash_fee'] = $this->accountlog->cash_fee($user['user_id']);
		$data['cash_fee'] = min($data['cash_fee'],$data['account']['use_money']);
		
		$data['account_tyj'] = $this->accountlog->get_sum_type($user['user_id'], EXP_MONEY);
		$data['account_tyj_kc'] = $this->accountlog->get_sum_type($user['user_id'], EXP_MONEY_DEDUCT);
		$data['account_tyj'] = $data['account_tyj']-$data['account_tyj_kc'];
		
		if($act == 'submit'){
		if($data['user']['mmm_id'] == ""){
				$this->js->alert('请先开通资金托管');
				$this->js->go('/user/realname.html');
				exit;
			}else{
				$captcha = $this->input->post('captcha');
				$paypwd = $this->input->post('paypwd');
				$money  = $this->input->post('money');
				if($captcha == ''){
					$this->js->alert('验证码不能为空');
					$this->js->go('');
					exit;
				}
				if ($captcha!=$_SESSION['captcha']){
					$this->js->alert('验证码不正确');
					$this->js->go('');
					exit;
				}
				if(!is_numeric($money)){
					$this->js->alert('无效金额');
					exit;
				}
				$money = round($money,2);
				if($money < 100){
					$this->js->alert('单笔提现最低金额100元');
					$this->js->go('');
					exit;
				}
				if($money > 1000000){
					$this->js->alert('单笔提现最高金额1000000元');
					$this->js->go('');
					exit;
				}
				
				if(md5(md5($paypwd)) == $data['user']['paypassword']){
					$account_result =  $data['account'];
				
					if(($account_result['use_money'] - $data['account_tyj']) < $money){
						$this->js->alert('可用余额不足');
						$this->js->go('');
						exit;
					}else{
						$time = time();
						$ip = $this->input->ip_address();
						$fee = CASH_FEE>0 ? round($money * CASH_FEE,2):0;
						if($fee < 1){
							$fee = 1;							
						}
						$this->db->trans_begin();//事务开始
						//添加提现表记录
						$setArr = array(
							'user_id' => $user['user_id'],
							'fstatus' => '0',
							'account' => $data['bank']['account'],
							'bank' => $data['bank']['bank'],
							'branch' => $data['bank']['branch'],
							'province' => $data['bank']['province'],
							'city' => $data['bank']['city'],
							'total' => $money,
							'credited' => $money - $fee,
							'fee' =>$fee,
							'add_time' => $time,
							'addip' => $ip
						);
						$this->load->model('Accountcash_model', 'cash');
						$ret = $this->cash->add($setArr);
						//添加提现冻结资金日志
						if($ret > 0){
							$log = array(
								'user_id' => $user['user_id'],
								'ftype' => CASH_FROST,
								'money' => $money,
								'total' => $account_result['total'],
								'use_money' => $account_result['use_money']-$money,
								'no_use_money' => $account_result['no_use_money']+$money,
								'collection' => $account_result['collection'],
								'to_user' => 0,
								'add_time' => $time,
								'addip' => $ip,
								'remark' => "提现冻结"
							);
							$ret1 = $this->account->addlog($log);

                            //发送提现成功站内信
                            $this->Message_model->send(array('sent_user' => 1, 'receive_user' => $user['user_id'],
                                'name' => "恭喜您提现成功，金额为{$money}.",
                                'fstatus' => 0,
                                'message_type' => 'system',
                                'sented' => 0,
                                'deltype' => 0,
                                'content' => "恭喜您提现成功，金额为{$money}.【华银资本】",
                                'add_time' => time(),
                                'addip' => $this->js->get_ip()
                            ));
						}
						
						if($ret){
							$this->db->trans_commit();
							header("Location:/moneymoremore/toloanwithdraws/".$ret);
							exit;
						}else{
							$this->db->trans_rollback();
							$this->js->alert('操作失败，请重试');
							$this->js->go('/account/cash/index.html');
							exit;
						}
					}
				}else{
					$this->js->alert('交易密码不正确');
					$this->js->go('/account/cash/index.html');
					exit;
				}
			}
		}else{
			$data['title'] = "账户提现".' - '.CON_KEYWORDS;
            $data['tab_first'] = 'fund';
            $data['tab_second'] = 'fund_withdraw';
			$this->load->view('account/account_cash', $data);
		}
	}
	
	function cashed(){
		$user = $this->session->userdata('zjy_user');
		$data = array();
		$parms['page_start'] = intval($this->input->get('per_page'));
		$parms['page_size'] = 10;
		$parms['where']['user_id'] = $user['user_id'];
		$this->load->model('Accountcash_model', 'cash');
		$data = $this->get_user_info('account_cashed','account_info');
		
		$resData = $this->cash->get_accountcash_list($parms);
		$data['list'] = $resData['accountcash_list'];
		$data['sum_money'] = $this->cash->get_succ_total($user['user_id']);
		$data['cash_status'] 	= $this->cash->arrays("account_cash_status");
		$data['bank_list'] = $this->cash->arrays("account_bank");
		$this->load->library('pagination');
		$config['base_url'] = '/account/cashed/index.html?';
		$config['total_rows'] = $resData['accountcash_count'];
		$config['per_page'] = 10;
		$config['first_link'] = '首页';
		$config['next_link'] = '下一页';
		$config['prev_link'] = '上一页';
		$config['last_link'] = '尾页';
		$this->pagination->initialize($config);
		
		
		$data['title'] = "提现记录".' - '.CON_KEYWORDS;
        $data['tab_first'] = 'fund';
        $data['tab_second'] = 'fund_withdraw';
		$this->load->view('/account/account_cash_log', $data);
	}
	
	function cash_cancel($id=0){
		$ret = array('msg'=>'错误操作','url'=>'/account/cashed');
		$id = intval($id);
		$user = $this->session->userdata('zjy_user');
		if($id<1 || !isset($user['user_id']) || !$user['user_id']){
			echo json_encode($ret);
			exit;
		}
		$this->load->model('Accountcash_model');
		$this->load->model('Account_model');
		$cash = $this->Accountcash_model->get_by_id($id);
		if($cash['user_id'] != $user['user_id']){
			echo json_encode($ret);
			exit;
		}
		if($cash['fstatus'] != 0){
			echo json_encode($ret);
			exit;
		}
		
		$this->db->trans_begin();//事务开始
		$setArr["fstatus"] = 3;
  		$result = $this->Accountcash_model->update($id, $setArr);
  		if($result){
  			$account = $this->Account_model->get_account($cash['user_id']);
  			$log = array(
  				'user_id' => $cash['user_id'],
  				'ftype' => CASH_CANCEL,//提现取消
  				'total' => $account['total'],
  				'money' => $cash['total'],
  				'use_money' => $account['use_money']+$cash['total'],
  				'no_use_money' => $account['no_use_money']-$cash['total'],
  				'collection' => $account['collection'],
  				'to_user' => 1,
  				'remark' => '提现取消',
  				'add_time' => time(),
  				'addip' => $this->input->ip_address(),
  			);
  			$result = $this->Account_model->addlog($log);
  		}
  		
		if($result){
			$this->db->trans_commit();
			$ret['msg']='操作成功';
			$ret['url']='';
			echo json_encode($ret);
			exit;
		}else{
			$this->db->trans_rollback();
			$ret['msg']='操作失败';
			$ret['url']='';
  			echo json_encode($ret);
			exit;
		}
		
		
	}
	
	function details(){
		$act = $this->input->get('act');
		if ($act == 'excel'){
			$this->detailsexcel();
		}else{
			$user = $this->session->userdata('zjy_user');
			$data = array();
			$parms['page_start'] = intval($this->input->get('per_page'));//intval($page);
			$parms['page_size'] = 20;
			$parms['where']['user_id'] = $user['user_id'];
			$parms['where']['strtime'] = $this->input->get('start_time');
			$parms['where']['endtime'] = $this->input->get('end_time');
			$parms['where']['ftype'] = $this->input->get('type');
			$this->load->model('Accountlog_model', 'accountlog');			
			
			$data = $this->get_user_info('account_detail','account_detail');
			
			$resData = $this->accountlog->get_accountlog_list($parms);
			$data['list'] = $resData['accountlog_list'];
			$data['log_type'] 	= $this->accountlog->arrays("account_type");
			//$this->config->set_item('enable_query_strings', 'false');
			$this->load->library('pagination');
			$config['base_url'] = '/account/details.html?start_time='.$parms['where']['strtime'].'&end_time='.$parms['where']['endtime'].'&type='.$parms['where']['ftype'];
			$config['total_rows'] = $resData['accountlog_count'];
			$config['per_page'] = 20;
			//$config['page_query_string'] = false;
			$config['first_link'] = '首页';
			$config['next_link'] = '下一页';
			$config['prev_link'] = '上一页';
			$config['last_link'] = '尾页';
			$this->pagination->initialize($config);
			$data['where'] = $parms['where'];
			$data['title'] = "资金明细".' - '.CON_KEYWORDS;
            $data['tab_first'] = 'fund';
            $data['tab_second'] = 'fund_deal';
			$this->load->view('/account/account_log', $data);
		}
	}
	
	function detailsexcel(){
		$user = $this->session->userdata('zjy_user');
		$parms['where']['user_id'] = $user['user_id'];
		$parms['where']['strtime'] = $this->input->get('start_time');
		$parms['where']['endtime'] = $this->input->get('end_time');
		$parms['where']['ftype'] = $this->input->get('type');
		$parms['limit'] = 'all';
		$this->load->model('Accountlog_model', 'accountlog');
		$logType = $this->accountlog->arrays("account_type");
		$resData = $this->accountlog->get_accountlog_list($parms);
		$list = $resData['accountlog_list'];
		
		$this->load->library('PHPExcel');
		$this->load->library('PHPExcel/IOFactory'); 
		$objPHPExcel = new PHPExcel();
		$objPHPExcel->getProperties()->setTitle("资金明细")->setDescription(COMPANY_NAME); 
		$objPHPExcel->setActiveSheetIndex(0);
		$titles = array("类型", "操作金额", "总金额", "可用金额", "冻结金额", "待收金额", "记录时间", "备注");
		for($i = 0; $i < count($titles); $i ++){
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, 1, $titles[$i]);
		}
		
		for($i = 0; $i < count($list); $i++){
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $i+2, $logType[$list[$i]['ftype']]);
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $i+2, $list[$i]['money']);
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $i+2, $list[$i]['total']);
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $i+2, $list[$i]['use_money']);
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $i+2, $list[$i]['no_use_money']);
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $i+2, $list[$i]['collection']);
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $i+2, date('Y-m-d H:i:s',$list[$i]['add_time']));
			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $i+2, $list[$i]['remark']);
			
		}
		
		$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel5'); 
		//发送标题强制用户下载文件 
		header('Content-Type: application/vnd.ms-excel'); 
		header('Content-Disposition: attachment;filename="资金明细.xls"'); 
		header('Cache-Control: max-age=0'); 
		$objWriter->save('php://output'); 
	}
	
	function info(){
		$data = array();
		$user = $this->session->userdata('zjy_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			$this->load->model('Account_model');
			$this->load->model('Borrow_model');
			$this->load->model('Accountrecharge_model');
			$this->load->model('Accountcash_model');
			$this->load->model('Accountlog_model');
			
			$data = $this->get_user_info('account_info','account_info');
			
			
			//账户基本情况
			$data['account'] = $this->Account_model->get_account($user['user_id']);
			//用户各类充值汇总
			$data['recharge_group'] = $this->Accountrecharge_model->get_recharge_group_sum($user['user_id']);
			//用户充值手续费
			$data['recharge_fee'] = $this->Accountrecharge_model->get_recharge_fee_sum($user['user_id']);
			//用户提现总额
			$data['cash_group'] = $this->Accountcash_model->get_succ_total($user['user_id']);
			//用户操作金额分类汇总get_sum_group
			$data['log_group'] = $this->Accountlog_model->get_sum_group($user['user_id']);
			//投标总额
			$data['tender_total'] = $this->Borrow_model->tender_total($user['user_id']);
			//已收总额
			$collection_list = $this->Borrow_model->collection_total($user['user_id'], 1);
			//已收本金
			$data['ycollection_total'] = $collection_list['collection_total'];
			//已收本金
			$data['ycollection_capital'] = $collection_list['collection_capital'];
			//已收利息
			$data['ycollection_interest'] = $collection_list['collection_interest'];
			
			//代收总额
			$collection_list = $this->Borrow_model->collection_total($user['user_id'], 0);
			//代收总额
			$data['collection_total'] = $collection_list['collection_total'];
			//代收本金
			$data['collection_capital'] = $collection_list['collection_capital'];
			//代收利息
			$data['collection_interest'] = $collection_list['collection_interest'];
			//最近回款时间
			$data['first_collection_time'] = $this->Borrow_model->first_collection_time($user['user_id']);
			
			//代收本金
			$repayment_list_total = $this->Borrow_model->loan_repayment_total($user['user_id']);
			//借款总额
			$data['repayment_total'] = $repayment_list_total['capital_account'];
			$yrepayment_list_total = $this->Borrow_model->loan_repayment_total($user['user_id'], 1);
			//已还总额
			$data['yrepayment_total'] = $yrepayment_list_total['capital_account'];
			$wrepayment_list_total = $this->Borrow_model->loan_repayment_total($user['user_id'], 0);
			//未还总额
			$data['wrepayment_total'] = $wrepayment_list_total['repay_account'];
			
			//逾期赚取的费用
			$data['late_collection_account']  = $this->Accountlog_model->get_sum_type($user['user_id'] ,LATE_COLLECTION);
			//逾期支付费用
			$data['late_repayment_account']  = $this->Accountlog_model->get_sum_type($user['user_id'] ,LATE_REPAYMENT);
			
			$first_repayment_obj = $this->Borrow_model->first_repayment_time($user['user_id']);
			$data['first_repayment_time'] = 0;
			$data['first_repayment_account'] = 0;
			if(count($first_repayment_obj) > 0){
				$data['first_repayment_time'] = $first_repayment_obj['repayment_time'];
				$data['first_repayment_account'] = $first_repayment_obj['repayment_account'];
			}
			
			//最近7天资金统计
			$this->load->model('Mydb_model');
			$tmp = array();
			for ($i = 0; $i < 7; $i++) {
				$time = strtotime(date('Y-m-d')) - $i*3600*24;
				$timeEnd = $time+3600*24;
				$mode = $user['user_id']%100;
				$sql = "select ftype,sum(money) as tmoney from zjy_account_log_$mode where user_id=".$user['user_id']." and add_time>=$time and add_time<$timeEnd group by ftype";
				$ret = $this->Mydb_model->query_sql($sql,'list');
				$sql = "select sum(fee) as tx_fee from zjy_account_cash where user_id=".$user['user_id']." and verify_time>=$time and verify_time<$timeEnd";
				$row = $this->Mydb_model->query_sql($sql,'row');
				$k = date('Y-m-d',$time);
				$tmp2 = array();
				foreach($ret as $v){
					$tmp2[$v['ftype']] = $v['tmoney'];
				}
				$tmp2['tx_fee'] = $row['tx_fee'];
				$tmp[$k] = $tmp2;
			}
			
			$data['week_log'] = $tmp;
			
			$data['title'] = "账户详情".' - '.CON_KEYWORDS;
            $data['tab_first'] = 'fund';
            $data['tab_second'] = 'fund_overview';
			$this->load->view('/account/account_info', $data);
		}
		
	}
	
}